<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="utf-8">
    <title>
        后台管理系统
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="./css/x-admin.css" media="all">
    <link rel="stylesheet" href="./lib/layui-v2.5.5/css/layui.css">
</head>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>会员管理</cite></a>
              <a><cite>问题/资讯列表</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">

    <button class="layui-btn" onclick="question_add('添加问题','admins-add.jsp','600','500')"><i class="layui-icon">&#xe608;</i>添加</button></xblock>
    <script type="text/html" id="toolbar1"></script>
    <table class="layui-hide" id="current" lay-filter="currentTableFilter"></table>
    <script type="text/html" id="toolBar2" lay-filter="test1">
        <a type="submit" class="layui-btn layui-btn-normal layui-btn-sm"
        onclick="question_edit('编辑','/adminsedit?aid={{d.aid}}','600','500')">
            <i class="layui-icon">&#xe642;</i>
        </a>
    </script>
</div>

<script src="./lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="./js/x-layui.js" charset="utf-8"></script>
<script>
    layui.use(['table','jquery','layer'],function (){
        $=layui.jquery,
        layer=layui.layer,
        table=layui.table
        var tables=table.render({
            elem: '#current',
            url: '/AdminShow',
            toolbar:'#toolbar1',
            cols: [[
                {field: 'aid', title: '编号', sort: true, width: 100},
                {field: 'ano', title: '账号', width: 120},
                {field: 'apwd', title: '密码', width: 120},
                {field: 'aname', title: '姓名', width: 120},
                {field: 'agender', title: '性别', width: 100},
                {field: 'address', title: '住址', width: 150},
                {field: 'atel', title: '电话', width: 120},
                {field: 'aemail', title: '邮箱', width: 120},
                {
                    field: 'status', title: '状态', width: 120, templet: function (d) {
                        let type = d.status;
                        let state = type == 1 ? '启用' : '禁用'
                        return state;
                    }
                },
                {title: '操作', toolbar: '#toolBar2', width: 120, align: 'center'}
            ]],
            limits: [5, 10, 20, 50, 100],
            limit: 5,//每页显示几行数据
            page: true,//允许分页
            parseData: function (res) {
                return{
                    "code":0,
                    "count":res.count,
                    "data":res.data
                };
            },
            done: function (res, curr, count) {

            }
        });
    });

    //批量删除提交
    function delAll () {
        layer.confirm('确认要删除吗？',function(index){
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
        });
    }

    function question_show (argument) {
        layer.msg('可以跳到前台具体问题页面',{icon:1,time:1000});
    }
    /*添加*/
    function question_add(title,url,w,h){
        x_admin_show(title,url,w,h);
    }
    //编辑
    function question_edit (title,url,id,w,h) {
        x_admin_show(title,url,w,h);
    }

    /*删除*/
    function question_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $(obj).parents("tr").remove();
            layer.msg('已删除!',{icon:1,time:1000});
        });
    }
</script>

</body>
</html>
